from django.db import models

# Create your models here.
class Config(models.Model):
    no = models.CharField(max_length=50, blank=False, null=False, unique=True, verbose_name="编码")
    name = models.CharField(max_length=100, verbose_name="名称")
    value = models.FloatField(default=None, blank=True, null=True, verbose_name="数值")
    status = models.PositiveSmallIntegerField(choices=((1, "有效"), (0, "无效")), editable=False, default=1, verbose_name="状态")
    comment = models.CharField(max_length=100, default=None, blank=True, null=True, verbose_name="备注")
    create_time = models.DateTimeField(verbose_name="创建时期", auto_now_add=True)
    update_time = models.DateTimeField(verbose_name="修改时间", auto_now=True)

    def __str__(self):
        return '{}'.format(self.no)

    class Meta:
        verbose_name = "配置表"
        verbose_name_plural = verbose_name

# 基类
class BaseInfo(models.Model):
    status = models.PositiveSmallIntegerField(choices=((1, "有效"), (0, "无效")), default=1, verbose_name="状态")
    comment = models.CharField(max_length=256, blank=True, null=True, verbose_name="备注")
    created_date = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
    modified_date = models.DateTimeField(auto_now=True, verbose_name="修改时间")

    class Meta:
        abstract = True